<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    function f1(x,y) {
        x = x || 1;
        y = y || 2;
        console.log(x+y);
    }
    f1(3,5);
    f1("3","5");
    f1();
    f1(0,0);
    console.log("----")
    /*es6中支持给函数的参数列表直接赋值，表示该参数的默认值，默认值只在null或者undefined时生效*/
    function f2(x=1,y=2) {
        console.log(x+y)
    }
    f2(4,8);
    f2();
    f2(0,0);



    function success(res={}) {
        if(res.code===200){
            console.log(res.msg)
        }
    }

    function suc({code=200,msg='hahahah'}={}) {
        if(code === 200){
            console.log(msg)
        }
    }

    success({code:200,msg:"success"})
    success()
    suc({code:200});
    suc();
</script>
</html>
